<template>
	<view :class="lang">
		<u-navbar :is-fixed="true" title=" " back-icon-name="arrow-leftward" :background="background"></u-navbar>
		<view  :class="lang+'layout'">
		<view class="mockstitle bluetext font-45">
			<text v-if="kemu == 1">{{ $t('parctices.科目一模拟考试') }}</text>
			<text v-if="kemu == 4">{{ $t('parctices.科目四模拟考试') }}</text>
		</view>
		<view class="mockscon">
			<view class="mocksconview">
				<view class="mocksconleft"><text>{{ $t('parctices.考试科目') }}</text></view>
				<view class="mocksconright">
					<text v-if="kemu == 1">{{ $t('indexs.科目一') }}</text>
					<text v-if="kemu == 4">{{ $t('indexs.科目四') }}</text>
					<text v-if="kemu == 0">{{ $t('settings.资格证') }}</text>
				</view>
			</view>
			<view class="mocksconview">
				<view class="mocksconleft"><text>{{ $t('parctices.准考车型') }}</text></view>
				<view class="mocksconright"><text>{{$t('settings.'+cartype)}} </text></view>
			</view>
			<view class="mocksconview">
				<view class="mocksconleft"><text>{{ $t('parctices.考试标准') }}</text></view>
				<view class="mocksconright"><text>{{surah}} {{ $t('keeping.题') }}，{{shijian}} {{ $t('keeping.分钟') }}</text></view>
			</view>
			<view class="mocksconview">
				<view class="mocksconleft"><text>{{ $t('parctices.合格标准') }}</text></view>
				<view class="mocksconright"><text>{{hege}} {{ $t('keeping.分及格') }}</text></view>
			</view>
		</view>
		<view class="mockbuttonview">
			<button class="mockbutton font-35" @click="kaishi()"><text>{{ $t('parctices.开始考试') }}</text></button>
		</view>
	</view>
	</view>
</template>

<script>
	//#ifdef APP-PLUS
	import {
		isOpen,
		openDb,
		addTab,
		mergeSql,
		getDataList,
		addTabItem,
		closeSQL,
		deleteInformationType,
		getTable,
		getCount,
		updateSQL,
		isTable,
		selectDataList
	} from '@/js_sdk/lyz-sqlite/index.js';
	import { getFileName, getimgname } from '../../common/imgtool.js';
	//#endif
	
	import { getCarType, getArrEqual, getArrload } from '../../common/savetool.js';
	export default {
		data() {
			return {
				lang: this.$i18n.locale,
				kemu:1,
				subject:'',
				subarrid:[],
				background: {
									backgroundColor: '#ffffff',
								},
				hege:0,			//合格 多少分合格
				shijian:'',
				surah:0,
				cartype:'',
				lolang:'',
				subjectname:''
				
			}
		},
		onLoad(options) {
			var that = this;
			var kemu = options.kemu;
			if(kemu == undefined){
				uni.reLaunch({
					url:'../index/index'
				})
				return;
			}
			console.log("kemu==",kemu)
			that.kemu = kemu;
			if(this.$i18n.locale == 'cn'){
				that.lolang = 'CN';
			}
			if(this.$i18n.locale == 'uy'){
				that.lolang = 'UG';
			}
			if(this.$i18n.locale == 'kz'){
				that.lolang = 'KAZ';
			}
			
					
			uni.getStorage({
				key: 'cart_type',
				success: function(res) {
					console.log(res, '=====');
					console.log(res.data);
					
					that.cartype = res.data;
					
					
					console.log('getCarType--=', getCarType(res.data));
					that.subject = getCarType(res.data);
					if(that.kemu == 0){
							that.subjectname = '';
						}else{
							that.subjectname = getCarType(res.data);
						}
					
					that.kaoshi();
				}
			});
			// if (isOpen('data')) {
			// 	//数据库已打开
			// 	console.log('数据库已打开');
				
			// 	that.dbid(kemu);
						
			// } else {
			// 	//数据库没有打开  先打开
			// 	console.log('数据库未打开');
			// 	that.openDb();
			// }
		},
		methods: {
			kaishi(){
				var that = this;
				uni.navigateTo({
					url:'./exam?kemu='+that.kemu
				})
			},
			kaoshi(){
				var that = this;
				var dansane = 0;		//单选题数量
				var pansane = 0;		//判断题数量
				var duosane = 0;		//多选题数量
				var hege = 0;			//合格 多少分合格
				var shijian = 0;		//考试时间
				var kzshijian = 0;
				//车类型来判断  cart_type
				if(that.subject == 'C1C2C3' || that.subject == 'A2B2' || that.subject == 'A1A3B1'){
					if(that.kemu == 1){
						dansane = 60;		//单选题数量
						pansane = 40;		//判断题数量
						duosane = 0;		//多选题数量
						
					}else if(that.kemu == 4){
						dansane = 20;		//单选题数量
						pansane = 20;		//判断题数量
						duosane = 10;		//多选题数量
						
					}
					shijian = 45;
					kzshijian = 60;
					hege = 90;
				}else if(that.subject == 'DEF'){
					dansane = 30;		//单选题数量
					pansane = 20;		//判断题数量
					duosane = 0;		//多选题数量
					hege = 80;
					shijian = 45;
					kzshijian = 60;
				}else if(that.subject == 'Z_KEYUN'){
					dansane = 50;		//单选题数量
					pansane = 40;		//判断题数量
					duosane = 0;		//多选题数量
					hege = 80;
					shijian = 60;
					kzshijian = 60;
				}else if(that.subject == 'Z_HUOYUN'){
					dansane = 20;		//单选题数量
					pansane = 20;		//判断题数量
					duosane = 30;		//多选题数量
					hege = 80;
					shijian = 60;
					kzshijian = 60;
				}
				else if(that.subject == 'Z_WEIXIANPING'){
					dansane = 50;		//单选题数量
					pansane = 50;		//判断题数量
					duosane = 0;		//多选题数量
					hege = 90;
					shijian = 90;
					kzshijian = 90;
				}
				if(this.$i18n.locale != 'cn'){
					that.shijian = kzshijian;
				}else{
					that.shijian = shijian;
				}
				that.hege = hege;
				that.surah = dansane + duosane + pansane;
			},
			//打开数据库
			// openDb() {
			// 	var that = this;
			// 	if (isOpen('data')) return;
			// 	openDb('data').then(res => {
			// 		console.log(res);
					
			// 		that.dbid(that.kemu);
						
			// 	});
			// },
			
			// dbid(indexdata) {
				
			// }
			
		}
	}
</script>

<style>
	.mockbuttonview{
		width: 400rpx;
		height: 100rpx;
		padding-top: 100rpx;
		margin: 0 auto;
	}
	.mockbutton{
		width: 400rpx;
		height: 80rpx;
		line-height: 80rpx;
		background: #27c500;
		color: #FFFFFF;
		border-radius: 300rpx;
	}
	.kz .mockbutton{
		line-height: 90rpx;
	}
	.uy .mockbutton{
		line-height: 90rpx;
	}
.mockstitle{
	width: 750rpx;
	height: 100rpx;
	line-height: 100rpx;
	padding-top: 30%;
	text-align: center;
}
.mockscon{
	width: 700rpx;
	margin: 0 auto;
	display: block;
	padding-top: 200rpx;
}
.mocksconview{
	display: flex;
	align-items: center;
	justify-content: space-evenly;
	flex-wrap: wrap;
	width: 700rpx;
	height: 80rpx;
}

.mocksconleft{
	display: inline-block;
	width: 300rpx;
	height: 80rpx;
	line-height: 80rpx;
	text-align: right;
}
.mocksconright{
	display: inline-block;
	width: 400rpx;
	height: 80rpx;
	line-height: 80rpx;
	text-align: left;
}
.kz .mocksconleft{
	padding-right: 60rpx;
}
.kz .mocksconright{
	padding-left: 60rpx;
	text-align: right;
}
.uy .mocksconleft{
	padding-right: 60rpx;
}
.uy .mocksconright{
	padding-left: 60rpx;
	text-align: right;
}
</style>
